package com.weigang.controller;


import com.weigang.model.CustomMessage;
import com.weigang.producer.JmsProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private JmsProducer producer;

    @GetMapping("/send")
    public String sendMessage(@RequestParam String msg) {
        producer.sendMessage(msg);
        return "Message sent: " + msg;
    }

    @GetMapping("/sendObj")
    public String sendMessage(@RequestParam Integer id,@RequestParam String content) {
        CustomMessage customMessage = new CustomMessage(content, id);
        producer.sendMessage(customMessage);
        return "Message sent: " + customMessage;
    }
}
